|
class PolygonMesh |
|
Parent: Object |
|
|
Methods:new, add_point, add_polygon, count_points, count_polygons, normal_at, point_at, point_index, points, polygon_at, polygon_points_at, polygons, set_point, transform!, uvs, uv_at |
|
|
Sample Code: polygonmeshtests.rb |
|
|
Class Methods |
|
new |
|
The new method is used to create a new empty polygon mesh. |
|
Syntax: |
|
mesh = Geom::PolygonMesh.new numpoints, numpolygons |
|
Arguments: |
|
|
|
Return Value: |
|
|
|
Comments: |
|
The number of points and polygons are optional and are just used as a hint to decide how much space to pre-allocate to speed up adding points and polygons. |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
Instance Methods |
|
add_point |
|
The add_point method is used to add a point to the mesh. |
|
Syntax: |
|
index = polygonmesh.add_point point |
|
Arguments: |
|
point - a Point3D object |
|
Return Value: |
|
index - the index in the mesh for the point |
|
Comments: |
|
The index can be used for creating polygons. |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
add_polygon |
|
The add_polygon method is used for adding a polygon to a polygon mesh. |
|
Syntax: |
|
index = polygonmesh.add_polygon polygon |
|
Arguments: |
|
polygon - a polygon |
|
Return Value: |
|
index - the index of the polygon in the mesh if successful |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
count_points |
|
The count_points method is used to count the number of points in a mesh. |
|
Syntax: |
|
points = mesh.count_points |
|
Arguments: |
|
|
|
Return Value: |
|
points - the number of points in a mesh, if successful |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
count_polygons |
|
The count_polygons count the number of polygons in the mesh. |
|
Syntax: |
|
polygons = mesh.count_polygons |
|
Arguments: |
|
|
|
Return Value: |
|
polygons - the number of polygons in the mesh, if successful |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
normal_at |
|
The normal_at method is used to determine the normal at a particular index in the mesh. |
|
Syntax: |
|
normal = polygonmesh.normal_at index |
|
Arguments: |
|
index - the index in the mesh where the normal is that you want to retrieve |
|
Return Value: |
|
normal - a normal |
|
Comments: |
|
Index is 1 based (starts at 1). |
|
Example: |
|
normal = mesh.normal_at 1 |
|
point_at |
|
The point_at method is used to retrieve the point at a specific index in the mesh. |
|
Syntax: |
|
point = polygonmesh.point_at index |
|
Arguments: |
|
index - the index in the mesh where the point is that you want to retrieve |
|
Return Value: |
|
point - a Point3D object |
|
Comments: |
|
Index is 1 based (starts at 1). |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
point_index |
|
The point_index method is used to retrieve the index of a point in the mesh. |
|
Syntax: |
|
index = polygonmesh.point_index point |
|
Arguments: |
|
point - a Point3d object |
|
Return Value: |
|
index - the index in the mesh for the Point3d object |
|
Comments: |
|
Returns 0 if point is not found. |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
points |
|
The points method is used to retrieve an array of points (vertices) in the mesh |
|
Syntax: |
|
points = polygonmesh.points |
|
Arguments: |
|
|
|
Return Value: |
|
points - an array of points (vertices) if successful |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
polygon_at |
|
The polygon_at method is used to retrieve an array of vertex index values for a polygon at a specific index. |
|
Syntax: |
|
vertices = polygonmesh.polygon_at index |
|
Arguments: |
|
index - the index of the desired polygon |
|
Return Value: |
|
vertices - an array of vertex index values |
|
Comments: |
|
Index is 1 based (starts at 1). The returned array can contain negative values with the sign indicating a hidden edge. For example, a return value of [-1, 2, 3] indicates that the edge from 1 to 2 is hidden. The negative values should not be used as an index for point_at, take the positive value of the index value in the polygon array. So if you get [-1, 2,3] use 1 as the arg to point_at. |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
polygon_points_at |
|
The polygon_points_at method is used to retrieve the points for a polygon that is at a specific index in the mesh. |
|
Syntax: |
|
points = polygonmesh.polygon_points_at index |
|
Arguments: |
|
index - an index for a polygon in the mesh |
|
Return Value: |
|
points - an array of points that make up the polygon if successful |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
polygons |
|
The polygons method is used to retrieve an array of all polygons in the mesh. |
|
Syntax: |
|
polygons = polygonmesh.polygons |
|
Arguments: |
|
|
|
Return Value: |
|
polygons - an array of polygons if successful |
|
Comments: |
|
The returned array can contain negative values with the sign indicating a hidden edge. For example, a return value of [-1, 2, 3] indicates that the edge from 1 to 2 is hidden. |
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
set_point |
|
The set_point method is used to set the point at a specific index in the mesh. |
|
Syntax: |
|
polygonmesh = polygonmesh.set_point index, point |
|
Arguments: |
|
index - the index where the point will be set point - a Point3d object to set at the index |
|
Return Value: |
|
polygonmesh - a PolygonMesh object |
|
Comments: |
|
|
|
Example: |
|
mesh = Geom::PolygonMesh.new |
|
transform! |
|
The transform! method is used to apply a transformation to a mesh |
|
Syntax: |
|
polygonmesh = polygonmesh.transform! transformation |
|
Arguments: |
|
transformation - a Transformation object |
|
Return Value: |
|
polygonmesh - the PolygonMesh object |
|
Comments: |
|
|
|
Example: |
|
point = Geom::Point3d.new 100,200,300 |
|
uv_at |
|
The uv_at method is used to access a uv (texture coordinates) at a specific index. "UVs" is a way of referring to the u,v texture coordinates (as opposed to the X, Y, and Z axis that you construct your meshes on), which are points defining 1-by-1 positions within an image. These coordinates connect to points in your 3D model, to position an image texture onto it's surface (similar to virtual "thumb tacks") . These coordinates pin an exact spot on an image that you wish to use to texture your model to a specific point on an object's surface. Between these points, your software will stretch the image smoothly. This is what is referred to as UV mapping. |
|
Syntax: |
|
point = polygonmesh.uv_at index |
|
Arguments: |
|
index - the index for the texture coordinate |
|
Return Value: |
|
point - a Poin3d object where the x equals the u value and the y equals the v value. |
|
Comments: |
|
|
|
Example: |
|
point = mesh.uv_at(1,1) |
|
uvs |
|
The uvs method is used to retrieve a list of uvs. "UVs" is a way of referring to the u,v texture coordinates (as opposed to the X, Y, and Z axis that you construct your meshes on), which are points defining 1-by-1 positions within an image. These coordinates connect to points in your 3D model, to position an image texture onto it's surface (similar to virtual "thumb tacks") . These coordinates pin an exact spot on an image that you wish to use to texture your model to a specific point on an object's surface. Between these points, your software will stretch the image smoothly. This is what is referred to as UV mapping. |
|
Syntax: |
|
uvs = polygonmesh.uvs side |
|
Arguments: |
|
side - a boolean. If true, use the front uvs. If false, use the back uvs. |
|
Return Value: |
|
uvs - an array of uvs. |
|
Comments: |
|
The uvs must be generated with the parameters of 1 (Include PolygonMeshUVQFront) or 2 (Include PolygonMeshUVQBack). |
|
Example: |
|
uvs = mesh.uvs 1 |